/*
 * formateadorDecimal.java
 *
 * Created on September 16, 2007, 2:43 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package score.utils;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

/**
 *
 * @author Jose Luis Ortega
 */
public class formateadorDecimal {
    
    /** Creates a new instance of formateadorDecimal */
    public formateadorDecimal(){
        
    }
    public static String formateador(double numero) {
        DecimalFormatSymbols simbolos = new DecimalFormatSymbols();
        simbolos.setDecimalSeparator(',');
        simbolos.setGroupingSeparator('.');

        String patron = "#,##0.###";
        DecimalFormat formateador = new DecimalFormat(patron, simbolos);
        formateador.setGroupingSize(3);
        return formateador.format(numero);
    }
    
    public static double obtenerDouble(String numero){
         DecimalFormatSymbols simbolos = new DecimalFormatSymbols();
        simbolos.setDecimalSeparator(',');
        simbolos.setGroupingSeparator('.');

        String patron = "#,##0.###";
        DecimalFormat formateador = new DecimalFormat(patron, simbolos);
        formateador.setGroupingSize(3);
        try{
            return formateador.parse(numero).doubleValue();
        }catch(Exception ex){
            return 0987654321.0987654321;
        }
    }
}
